/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ventas_sie_apartados_detalle.java
 *
 * Created on 21/07/2011, 08:02:36 PM
 */

package sie_invdis;


import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;
import javax.swing.table.DefaultTableCellRenderer;
/**
 *
 * @author Michelle
 */
public class ventas_sie_apartados_detalle extends javax.swing.JFrame {

    private javax.swing.table.DefaultTableModel jtable_modelo;
     private javax.swing.table.DefaultTableModel jtable_modelo_movimientos;
     DefaultTableCellRenderer alinearCentro, alinearderecha, alinearIzquierda;
     String textohtml="";
    private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
    private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
    private int indexactual=0,yacarguecancel=0;
    //se crea intancia de la clase conexion
    bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
    ResultSet rs = null;
       //llamo almetodo para establecer la conexion
    /** Creates new form ventas_sie_apartados_detalle */
    public ventas_sie_apartados_detalle() {
        
        initComponents();
    }
 public ventas_sie_apartados_detalle(String idtienda,String folio) {
        
        this.iniciar_modelo_detalle_apartado();
        this.iniciar_modelo_detalle_movimientos();
        initComponents();
        this.carga_datos(2, idtienda, folio);
        this.carga_datos_detalle(0,idtienda,folio);
        this.carga_datos_detalle_cxc(1, idtienda, folio);

    jtbl_detalleapartado.getColumnModel().getColumn(0).setPreferredWidth(60);//Folio
    jtbl_detalleapartado.getColumnModel().getColumn(1).setPreferredWidth(120);//status
    jtbl_detalleapartado.getColumnModel().getColumn(2).setPreferredWidth(20);//doc ant.
    jtbl_detalleapartado.getColumnModel().getColumn(3).setPreferredWidth(30);//fecha
    jtbl_detalleapartado.getColumnModel().getColumn(4).setPreferredWidth(30);//fecha llega tienda
    jtbl_detalleapartado.getColumnModel().getColumn(5).setPreferredWidth(30);//f.recepcion

    jtbl_movimiento.getColumnModel().getColumn(0).setPreferredWidth(75);//Folio
    jtbl_movimiento.getColumnModel().getColumn(1).setPreferredWidth(30);//status
    jtbl_movimiento.getColumnModel().getColumn(2).setPreferredWidth(30);//doc ant.
    jtbl_movimiento.getColumnModel().getColumn(3).setPreferredWidth(50);//fecha
    this.setTitle("S.I. Apartados Detalle: Folio:"+folio+" Cliente:"+this.jtf_cliente.getText());
    this.centrar_datos();
    }
  public ventas_sie_apartados_detalle(int opcion,String idtienda,String folio) {
          this.iniciar_modelo_detalle_apartado();
        this.iniciar_modelo_detalle_movimientos();
        initComponents();

       switch (opcion) {
            case 1:
                        this.carga_datos(2, idtienda, folio);
                        this.carga_datos_detalle(0,idtienda,folio);
                        this.carga_datos_detalle_cxc(1, idtienda, folio);
            break;
            case 2:
                        this.carga_datos_credito(2, idtienda, folio);
                        this.carga_datos_detalle_credito(0, idtienda, folio);
            break;
        }



    jtbl_detalleapartado.getColumnModel().getColumn(0).setPreferredWidth(60);//Folio
    jtbl_detalleapartado.getColumnModel().getColumn(1).setPreferredWidth(120);//status
    jtbl_detalleapartado.getColumnModel().getColumn(2).setPreferredWidth(20);//doc ant.
    jtbl_detalleapartado.getColumnModel().getColumn(3).setPreferredWidth(30);//fecha
    jtbl_detalleapartado.getColumnModel().getColumn(4).setPreferredWidth(30);//fecha llega tienda
    jtbl_detalleapartado.getColumnModel().getColumn(5).setPreferredWidth(30);//f.recepcion

    jtbl_movimiento.getColumnModel().getColumn(0).setPreferredWidth(75);//Folio
    jtbl_movimiento.getColumnModel().getColumn(1).setPreferredWidth(30);//status
    jtbl_movimiento.getColumnModel().getColumn(2).setPreferredWidth(30);//doc ant.
    jtbl_movimiento.getColumnModel().getColumn(3).setPreferredWidth(50);//fecha
    this.setTitle("S.I. Apartados Detalle: Folio:"+folio+" Cliente:"+this.jtf_cliente.getText());
    this.carga_datos_fotospaginacion(0);
    this.centrar_datos();
    }

   private void iniciar_modelo_detalle_apartado()
    {
        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Clave</b></html>");
        jtable_modelo.addColumn("<html><b>Descripcion</b></html>");
        jtable_modelo.addColumn("<html><b>Unidad</b></html>");
        jtable_modelo.addColumn("<html><b>Cant.</b></html>");
        jtable_modelo.addColumn("<html><b>Precio</b></html>");
        jtable_modelo.addColumn("<html><b>Desc</b></html>");
        jtable_modelo.addColumn("<html><b>Importe</b></html>");
    }
private void iniciar_modelo_detalle_movimientos()
    {
        jtable_modelo_movimientos=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_movimientos.addColumn("<html><b>Fecha</b></html>");
        jtable_modelo_movimientos.addColumn("<html><b>T/Pago</b></html>");
        jtable_modelo_movimientos.addColumn("<html><b>Importe</b></html>");
        jtable_modelo_movimientos.addColumn("<html><b>Cajera</b></html>");

    }

private void carga_datos(int opcion,String idtienda,String busca)
 {
        String fechacat = "",fechallegatienda="",fechaentrega="";
        DecimalFormat miformat = new DecimalFormat("###,###,###,###.##");
        String venci="";
        java.util.Date fechahoy=new Date();
        int diastrans=0;
       //invoco al metodo que trae el recordset de datos
       String arreglo_idtie[]=null;
       rs = x.sieuno_executediversosv2("select * from x1venta_apartados_catalogo("+opcion+","+idtienda+",'"+busca+"') as (idapartado integer,idremapartado integer,idnivel_1 integer,totalapartado double precision,idcatdescuento integer,idcliente integer,idstatus integer,totalventanodescuento real,descuento real,fecha date, hora time without time zone,idempleado integer,saldo double precision,nombre text,celular text,fechavenci date,dias integer,email text,direccion text,nombreestatus text);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                 arreglo_idtie=rs.getString ("nombre").toString().split(":");
                 this.jtf_tienda.setText(idtienda+":"+arreglo_idtie[0]);
                 this.jtf_status.setText(rs.getString ("idstatus")+":"+rs.getString ("nombreestatus"));
                 this.jtf_folio.setText(rs.getString ("idapartado"));
                 this.jtf_fechaapartado.setText(this.fechaeuropea(rs.getString ("fecha"))+" "+DiaSemana(this.fechaeuropea(rs.getString ("fecha"))));
                 if(rs.getString ("fechavenci") != null )
                     {
                        venci=this.fechaeuropea(rs.getString ("fechavenci"))+" "+DiaSemana(this.fechaeuropea(rs.getString ("fechavenci")));
                        this.jtf_vencimiento.setText(venci);
                     }
                 if(rs.getFloat("saldo") != 0 )
                     {
                        this.jtf_vencimiento.setText(venci.concat(this.mensajetiempo(rs.getInt("dias"))));
                     }
                     this.jtf_cliente.setText(rs.getString ("idcliente")+":"+arreglo_idtie[1]);
                     this.jtf_direccion.setText(rs.getString ("direccion"));
                     this.jtf_telefono.setText(rs.getString ("celular")+" "+rs.getString ("email"));
                     this.jtf_importe.setText(miformat.format(rs.getFloat("totalapartado")));
                     this.jtf_abonos.setText(miformat.format(rs.getFloat("totalapartado")-rs.getFloat("saldo")));
                     this.jtf_saldo.setText(miformat.format(rs.getFloat("saldo")));
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

}

private void carga_datos_credito(int opcion,String idtienda,String busca)
 {
        String fechacat = "",fechallegatienda="",fechaentrega="";
        DecimalFormat miformat = new DecimalFormat("###,###,###,###.##");
        String venci="";
        java.util.Date fechahoy=new Date();
        int diastrans=0;
       //invoco al metodo que trae el recordset de datos
       String arreglo_idtie[]=null;
       rs = x.sieuno_executediversosv2("select * from x1venta_credito_catalogo("+opcion+","+idtienda+",'"+busca+"','"+busca+"','"+busca+"') as (idcrecxc integer,idcredito integer,idnivel_1 integer,totalcredito real,idcatdescuento integer,idcliente integer,idstatus integer,totalcreditonodescuento real,descuento real,fechapago date,fecha date, hora time,idempleado integer,nombre text,celular text,email text,direccion text,nombreestatus text,dias integer);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                 arreglo_idtie=rs.getString ("nombre").toString().split(":");
                 this.jtf_tienda.setText(idtienda+":"+arreglo_idtie[0]);
                 this.jtf_status.setText(rs.getString ("idstatus")+":"+rs.getString ("nombreestatus"));
                 this.jtf_folio.setText(rs.getString ("idcredito"));
                 this.jtf_fechaapartado.setText(this.fechaeuropea(rs.getString ("fecha"))+" "+DiaSemana(this.fechaeuropea(rs.getString ("fecha"))));
                 if(rs.getString ("fechapago") != null )
                     {
                        venci=this.fechaeuropea(rs.getString ("fechapago"))+" "+DiaSemana(this.fechaeuropea(rs.getString ("fechapago")));
                        //this.jtf_vencimiento.setText(venci);
                     }
                 //if(rs.getFloat("saldo") != 0 )
                  //   {
                   //     this.jtf_vencimiento.setText(venci.concat(this.mensajetiempo(rs.getInt("dias"))));
                    // }
                     this.jtf_cliente.setText(rs.getString ("idcliente")+":"+arreglo_idtie[1]);
                     this.jtf_direccion.setText(rs.getString ("direccion"));
                     this.jtf_telefono.setText(rs.getString ("celular")+" "+rs.getString ("email"));
                     this.jtf_importe.setText(miformat.format(rs.getFloat("totalcredito")));
                     //this.jtf_abonos.setText(miformat.format(rs.getFloat("totalapartado")-rs.getFloat("saldo")));
                     //this.jtf_saldo.setText(miformat.format(rs.getFloat("saldo")));
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

}

private void carga_datos_detalle(int opcion,String idtienda,String busca)
 {
        String fechacat = "",fechallegatienda="",fechaentrega="";
        DecimalFormat miformat = new DecimalFormat("###,###,###,###.##");
        java.util.Date fechahoy=new Date();

        Object[] fnewRow = new Object[12];
       //invoco al metodo que trae el recordset de datos
       String arreglo_idtie[]=null;
       rs = x.sieuno_executediversosv2("select * from x1venta_apartados_detalle("+opcion+",'"+busca+"',"+idtienda+") as (idapartado integer,cnsapartado integer,cantidadpro integer,idalmacen integer,descuento real,precio real,idproducto integer,describearticulo text,claveproducto text,importesindescuento double precision);",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {

                 fnewRow[0]=rs.getString ("claveproducto");
                 fnewRow[1]=rs.getString ("describearticulo");
                 fnewRow[2]="PZ";
                 fnewRow[3]=miformat.format(rs.getFloat("cantidadpro"));
                 fnewRow[4]=miformat.format(rs.getFloat("precio"));
                 fnewRow[5]=miformat.format(rs.getFloat("descuento"));
                 fnewRow[6]=miformat.format(rs.getFloat("importesindescuento"));
                 jtable_modelo.addRow(fnewRow);
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
}

private void carga_datos_detalle_credito(int opcion,String idtienda,String busca)
 {
        String fechacat = "",fechallegatienda="",fechaentrega="";
        DecimalFormat miformat = new DecimalFormat("###,###,###,###.##");
        java.util.Date fechahoy=new Date();

        Object[] fnewRow = new Object[12];
       //invoco al metodo que trae el recordset de datos
       String arreglo_idtie[]=null,texto="select * from x1venta_credito_catalogo_detalle("+opcion+","+idtienda+",'"+busca+"','','') as (idcredito integer,cntdet integer,cantidad real,idalmpro integer,descuento real,precio real,idproducto integer,desccorta text,claveproducto text,importesindesc double precision,ultimocosto numeric,famarti integer,idsubfam integer,item character varying(80),idtemingre smallint,nombrefamilia character varying(30),nombresubfamilia character varying(50),temporadaentrada character varying(25));";
            System.out.println(texto);
        try
         {
               rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
            while (rs.next())
                {

                 fnewRow[0]=rs.getString ("claveproducto");
                 fnewRow[1]=rs.getString ("desccorta");
                 fnewRow[2]="PZ";
                 fnewRow[3]=miformat.format(rs.getFloat("cantidad"));
                 fnewRow[4]=miformat.format(rs.getFloat("precio"));
                 fnewRow[5]=miformat.format(rs.getFloat("descuento"));
                 fnewRow[6]=miformat.format(rs.getFloat("importesindesc"));
                 jtable_modelo.addRow(fnewRow);
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
}
private void carga_datos_detalle_cxc(int opcion,String idtienda,String busca)
 {
        String fechacat = "",fechallegatienda="",fechaentrega="";
        DecimalFormat miformat = new DecimalFormat("###,###,###,###");
        java.util.Date fechahoy=new Date();
        Object[] fnewRow = new Object[4];
       //invoco al metodo que trae el recordset de datos
       String texto="",abrehtml="",cierrahtml="";
        try
         {
               texto="select * from x1venta_cobros_detalle_apartadosv2("+opcion+",'"+idtienda+"','"+busca+"','') as (idremision integer,idtipopago integer,cantidad double precision,cantidadpesos double precision,idniv2 integer,fecha date,hora time,idniv1 integer,folioimpreso bigint,idempleacobra integer,nombretipopago character varying(15),nombrecajero text,apaternocajero text,idapartado integer,totalventa real,idcliente integer);";
               System.out.println(texto);
               rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
               while (rs.next())
                    {
                     abrehtml="<html>";
                     cierrahtml="</html>";
                     fnewRow[0]=abrehtml+this.fechaeuropea(rs.getString("fecha"))+" "+rs.getString("hora").substring(0, 5)+cierrahtml;
                     fnewRow[1]=abrehtml+rs.getString("idtipopago")+":"+rs.getString("nombretipopago").toUpperCase()+cierrahtml;
                     fnewRow[2]=abrehtml+miformat.format(rs.getFloat("cantidadpesos"))+cierrahtml;
                     fnewRow[3]=abrehtml+rs.getString("nombrecajero").toUpperCase()+" "+rs.getString("apaternocajero").toUpperCase()+cierrahtml;
                     jtable_modelo_movimientos.addRow(fnewRow);
                    }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
}

 //cancelaciones
private void carga_datos_cobros_cancelacion(int opcion,String tienda,String busca1,String busca2)
    {
        DecimalFormat miformat = new DecimalFormat("###,###,###,###");

        String texto="",abrehtml="",cierrahtml="",razon="";
        Object[] fnewRow = new Object[12];

        try
         {
               texto="select * from x1venta_cobros_detalle_apartados_cancela("+opcion+",'"+tienda+"','"+busca1+"','"+busca2+"') as (idcancelacion integer,idniv3 integer,razon text,pesosomonedero integer,fechacancela date,horacancela time with time zone,idempleacancela integer,idniv2 integer,foliocancela integer,idremision integer,cantidad double precision,fechacobro date,horacobro time,folioimpreso bigint,idempleacobra integer,nombrecajero text,apaternocajero text,idapartado integer,importependiente double precision,idcliente integer);";
               System.out.println(texto);
               rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
               while (rs.next())
                    {
                     abrehtml="<html><b><font color=#CC0000>";
                     cierrahtml="<font></b></html>";

                         switch (rs.getInt("pesosomonedero"))
                        {

                            case 1:
                                fnewRow[1]=abrehtml+"5"+":"+"MONEDERO"+cierrahtml;
                            break;
                            case 2:
                                fnewRow[1]=abrehtml+"1"+":"+"EFECTIVO"+cierrahtml;
                            break;
                            default:
                                fnewRow[1]=abrehtml+"5"+":"+"MONEDERO"+cierrahtml;
                            break;
                        }
                     fnewRow[0]=abrehtml+this.fechaeuropea(rs.getString("fechacancela"))+" "+rs.getString("horacancela").substring(0, 5)+cierrahtml;

                     fnewRow[2]=abrehtml+miformat.format(rs.getFloat("cantidad"))+cierrahtml;
                     fnewRow[3]=abrehtml+rs.getString("nombrecajero").toUpperCase()+" "+rs.getString("apaternocajero").toUpperCase()+cierrahtml;
                     jtable_modelo_movimientos.addRow(fnewRow);
                     razon=this.jtp_razoncancela.getText()+" ";
                     this.jtp_razoncancela.setText(razon+" "+rs.getString("razon").toUpperCase());
                    }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
 }

    private void carga_datos_fotospaginacion(int pagina)
    {
        textohtml="";
        int nif=0,pag=pagina,nobjetotabla=this.jtable_modelo.getRowCount(),nip=0,ni=0,fila=0,artxpag=Integer.valueOf(this.jtf_fotosartxpag1.getText().toString());
        float totalpaginas=this.jtable_modelo.getRowCount()/artxpag;

        this.jlbl_paginas2.setText("PAGINAS :"+totalpaginas);
             nif=((pag+1)*artxpag);
             nip=((pag)*artxpag);
                        if (nif < nobjetotabla )
                            {
                                nobjetotabla=nif;
                            }
                    System.out.println("filas x pagina"+artxpag+"tOTAL FILAS:"+this.jtable_modelo.getRowCount()+" PAGINA ACTUAL "+pagina+" filainicial "+ nip + " Fila Final"+ nobjetotabla);
                    /*Impresion de los productos*/
                        for(ni=nip;ni<nobjetotabla;ni++)
                        {
                            System.out.println(" fila Actual "+ ni );
                                if (fila<=0)
                                    {
                                    	textohtml+= "<tr>";
                                    }
                                    fila++;
                                    textohtml+="<th>"+jtable_modelo.getValueAt(ni, 0).toString()+"<br>"+jtable_modelo.getValueAt(ni, 1).toString() + " $"+jtable_modelo.getValueAt(ni, 4).toString()+ "<br>"+"<img src=\"http://"+variables_global.getHostfotos()+"/"+variables_global.getcarpetaaplicacion()+"/fotos/"+jtable_modelo.getValueAt(ni, 0).toString()+".JPG\" width=230 height=190 border=0 alt=\"Foto Articulo\" />"+"</th>";
                                 if (fila>=4)
                                    {
                                        textohtml+= "</tr>";
                                        fila=0;
                                    }
                        }
         this.jepn_fotos.setText("<html><head></head><body><table>"+textohtml+"</table></body></html>");
         System.out.println(" este es html "+ textohtml );
    }

    public void centrar_datos()
    {
        alinearderecha = new DefaultTableCellRenderer();
        alinearderecha.setHorizontalAlignment(SwingConstants.RIGHT);

                jtbl_detalleapartado.getColumnModel().getColumn(4).setCellRenderer(alinearderecha);
                jtbl_detalleapartado.getColumnModel().getColumn(6).setCellRenderer(alinearderecha);

    }


  private String  fechaeuropea(String fecha) {

         //resibe cadena de fecha en formato americano yyyy-MM-dd
        java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;

    }
private String DiaSemana(String fe) {
         String dia = "";
       java.util.Date fecha=null;
         try
            {
             fecha = formateador.parse(fe);

           }
        catch (ParseException e)
            {
            //Error, la cadena de texto no se puede convertir en fecha.
            }
        Calendar cal= Calendar.getInstance();
        cal.setTime(fecha);
        //ojo para establecer o recetear cada parte de la fecha por separado
        //cal.set(Calendar.YEAR, fecha.getYear());
        //cal.set(Calendar.MONTH, fecha.getMonth());
        //cal.set(Calendar.DAY_OF_MONTH, fecha.getDay());
        int diaInt = cal.get(Calendar.DAY_OF_WEEK);
        switch (diaInt) {
            case 1:
                dia = "Domingo";
                break;
            case 2:
                dia = "Lunes";
                break;
            case 3:
                dia = "Martes";
                break;
            case 4:
                dia = "Miercoles";
                break;
            case 5:
                dia = "Jueves";
                break;
            case 6:
                dia = "Viernes";
                break;
            case 7:
                dia = "Sabado";
                break;

        }
        return dia;
    }

private  void ayuda()
            {
                JOptionPane.showMessageDialog(null," 1.-Catalogo de Recepciones de Mercancia, cada una de las Opciones se autodescribe brevemente\n 2.- Cada Boton tiene Una letra Resaltada el cual indica su metodo abreviado, uselo si desea mayor rapides ( ejemplo Alt+a obtendra ayuda automaticamente)\n 3.- Para ver Detalle de un documento de Doble clik sobre el registro sombreado o use las teclas arriba o abajo luego precione enter y aparecera otra pantalla. \n ", "Sistema Integral(Detalle Recepcion) : Ayuda",1);
            }

private void crearcomentario()
          {
                 String retorno="";

        String comentario=JOptionPane.showInputDialog("Ingresa Tu Sugerencia o Comentario:");
        if (comentario.length()>0)
        {
            rs = x.sieuno_executediversosv2("select * from x1distribucion_bitacorainserta('"+comentario+"', 'Catalogo Recepciones');",variables_global.getconexiongral());
            try
            {

               while (rs.next())
                    {
                         retorno=rs.getString(1);
                   }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
            if (retorno.equals("1"))
              {
                JOptionPane.showMessageDialog(null,"Gracias Tu comentario ha sido guardado", "Sistema Integral Comentarios",1);

              }

      }
    }

private int fechasDiferenciaEnDias(Date fechaInicial, Date fechaFinal) {

      Calendar grefechamesini = Calendar.getInstance(); // obtiene la fecha actual
       grefechamesini.set(fechaInicial.getYear()+1900,fechaInicial.getMonth(),fechaInicial.getDate());
      Calendar grefechamesfin = Calendar.getInstance(); // obtiene la fecha actual
      grefechamesfin.set(fechaFinal.getYear()+1900,fechaFinal.getMonth(),fechaFinal.getDate());

     int dias=grefechamesfin.get(Calendar.DAY_OF_YEAR)-grefechamesini.get(Calendar.DAY_OF_YEAR);
     /*
        DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
        String fechaInicioString = df.format(fechaInicial);
            try {
                fechaInicial = df.parse(fechaInicioString);
                }
                catch (ParseException ex) {
                }

        String fechaFinalString = df.format(fechaFinal);
                try {
                    fechaFinal = df.parse(fechaFinalString);
                    }
                catch (ParseException ex) {
                    }

            long fechaInicialMs = fechaInicial.getTime();
            long fechaFinalMs = fechaFinal.getTime();
            long diferencia = fechaFinalMs - fechaInicialMs;
            double dias = Math.floor(diferencia / (1000 * 60 * 60 * 24));
      */
            return dias;
    }

 private String mensajetiempo(int nd) {
     String mensaje="";
     if (nd==0)
				{
					mensaje=" Hoy ";
				}
		if (nd==1)
				{
					mensaje=" ayer ";
				}
		if (nd>1)
				{
					mensaje=" Hace " + nd + " Dias " ;
				}
     if (nd<0)
				{
					mensaje=" Vence En " + nd + " Dias " ;
				}
 	return mensaje;
 }

  private Date fechadecadenaadate(String fe) {
      //recibe un la fecha en strin formato yyyy-MM-dd
       String dia = "";
       java.util.Date fecha=null;
       try{
             fecha = formateadoresta.parse(fe);
          }
        catch (ParseException e){
           //Error, la cadena de texto no se puede convertir en fecha.
          }

        return fecha;
 }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jtf_tienda = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jtf_status = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtf_fechaapartado = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtf_folio = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtf_cliente = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtf_direccion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtf_telefono = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtf_vencimiento = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jtf_importe = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtf_abonos = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jtf_saldo = new javax.swing.JTextField();
        jtbn_clietestadistica = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtbl_movimiento = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtbl_detalleapartado = new javax.swing.JTable();
        jbtn_salir = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtp_razoncancela = new javax.swing.JEditorPane();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jepn_fotos = new javax.swing.JEditorPane();
        jtf_fotosartxpag1 = new javax.swing.JTextField();
        jlbl_paginas2 = new javax.swing.JLabel();
        jbtn_anterior1 = new javax.swing.JButton();
        jtf_paginaactual1 = new javax.swing.JTextField();
        jbtn_siguiente1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmni_salir = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jmni_escapar = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(ventas_sie_apartados_detalle.class);
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jtf_tienda.setEditable(false);
        jtf_tienda.setText(resourceMap.getString("jtf_tienda.text")); // NOI18N
        jtf_tienda.setName("jtf_tienda"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jtf_status.setEditable(false);
        jtf_status.setText(resourceMap.getString("jtf_status.text")); // NOI18N
        jtf_status.setName("jtf_status"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jtf_fechaapartado.setEditable(false);
        jtf_fechaapartado.setText(resourceMap.getString("jtf_fechaapartado.text")); // NOI18N
        jtf_fechaapartado.setName("jtf_fechaapartado"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jtf_folio.setEditable(false);
        jtf_folio.setName("jtf_folio"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jtf_cliente.setEditable(false);
        jtf_cliente.setText(resourceMap.getString("jtf_cliente.text")); // NOI18N
        jtf_cliente.setName("jtf_cliente"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jtf_direccion.setEditable(false);
        jtf_direccion.setText(resourceMap.getString("jtf_direccion.text")); // NOI18N
        jtf_direccion.setName("jtf_direccion"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jtf_telefono.setEditable(false);
        jtf_telefono.setText(resourceMap.getString("jtf_telefono.text")); // NOI18N
        jtf_telefono.setName("jtf_telefono"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jtf_vencimiento.setEditable(false);
        jtf_vencimiento.setFont(resourceMap.getFont("jtf_vencimiento.font")); // NOI18N
        jtf_vencimiento.setText(resourceMap.getString("jtf_vencimiento.text")); // NOI18N
        jtf_vencimiento.setName("jtf_vencimiento"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jtf_importe.setEditable(false);
        jtf_importe.setFont(resourceMap.getFont("jtf_importe.font")); // NOI18N
        jtf_importe.setText(resourceMap.getString("jtf_importe.text")); // NOI18N
        jtf_importe.setName("jtf_importe"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jtf_abonos.setEditable(false);
        jtf_abonos.setFont(resourceMap.getFont("jtf_abonos.font")); // NOI18N
        jtf_abonos.setText(resourceMap.getString("jtf_abonos.text")); // NOI18N
        jtf_abonos.setName("jtf_abonos"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jtf_saldo.setEditable(false);
        jtf_saldo.setFont(resourceMap.getFont("jtf_saldo.font")); // NOI18N
        jtf_saldo.setText(resourceMap.getString("jtf_saldo.text")); // NOI18N
        jtf_saldo.setName("jtf_saldo"); // NOI18N

        jtbn_clietestadistica.setIcon(resourceMap.getIcon("jtbn_clietestadistica.icon")); // NOI18N
        jtbn_clietestadistica.setText(resourceMap.getString("jtbn_clietestadistica.text")); // NOI18N
        jtbn_clietestadistica.setToolTipText(resourceMap.getString("jtbn_clietestadistica.toolTipText")); // NOI18N
        jtbn_clietestadistica.setName("jtbn_clietestadistica"); // NOI18N
        jtbn_clietestadistica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtbn_clietestadisticaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_tienda, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_folio, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_status, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_telefono, javax.swing.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(jtbn_clietestadistica)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_direccion, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(15, 15, 15))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_fechaapartado, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_vencimiento, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_importe, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_abonos, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_saldo, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtf_tienda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jtf_folio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_status, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtf_fechaapartado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_vencimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtbn_clietestadistica)
                    .addComponent(jtf_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jtf_direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jtf_telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jtf_importe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jtf_abonos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(jtf_saldo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jtbl_movimiento.setModel(this.jtable_modelo_movimientos);
        jtbl_movimiento.setName("jtbl_movimiento"); // NOI18N
        jScrollPane2.setViewportView(jtbl_movimiento);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
        );

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N
        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jtbl_detalleapartado.setModel(this.jtable_modelo);
        jtbl_detalleapartado.setName("jtbl_detalleapartado"); // NOI18N
        jScrollPane1.setViewportView(jtbl_detalleapartado);

        jbtn_salir.setIcon(resourceMap.getIcon("jbtn_salir.icon")); // NOI18N
        jbtn_salir.setText(resourceMap.getString("jbtn_salir.text")); // NOI18N
        jbtn_salir.setName("jbtn_salir"); // NOI18N
        jbtn_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_salirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(719, Short.MAX_VALUE)
                .addComponent(jbtn_salir)
                .addGap(44, 44, 44))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 826, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_salir))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel5.setName("jPanel5"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jtp_razoncancela.setName("jtp_razoncancela"); // NOI18N
        jScrollPane3.setViewportView(jtp_razoncancela);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 512, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(276, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addContainerGap(322, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel5.TabConstraints.tabTitle"), jPanel5); // NOI18N

        jPanel6.setName("jPanel6"); // NOI18N

        jScrollPane6.setName("jScrollPane6"); // NOI18N

        jepn_fotos.setContentType(resourceMap.getString("jepn_fotos.contentType")); // NOI18N
        jepn_fotos.setName("jepn_fotos"); // NOI18N
        jScrollPane6.setViewportView(jepn_fotos);

        jtf_fotosartxpag1.setText(resourceMap.getString("jtf_fotosartxpag1.text")); // NOI18N
        jtf_fotosartxpag1.setToolTipText(resourceMap.getString("jtf_fotosartxpag1.toolTipText")); // NOI18N
        jtf_fotosartxpag1.setName("jtf_fotosartxpag1"); // NOI18N
        jtf_fotosartxpag1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_fotosartxpag1ActionPerformed(evt);
            }
        });

        jlbl_paginas2.setText(resourceMap.getString("jlbl_paginas2.text")); // NOI18N
        jlbl_paginas2.setName("jlbl_paginas2"); // NOI18N

        jbtn_anterior1.setIcon(resourceMap.getIcon("jbtn_anterior1.icon")); // NOI18N
        jbtn_anterior1.setText(resourceMap.getString("jbtn_anterior1.text")); // NOI18N
        jbtn_anterior1.setName("jbtn_anterior1"); // NOI18N
        jbtn_anterior1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_anterior1ActionPerformed(evt);
            }
        });

        jtf_paginaactual1.setText(resourceMap.getString("jtf_paginaactual1.text")); // NOI18N
        jtf_paginaactual1.setName("jtf_paginaactual1"); // NOI18N
        jtf_paginaactual1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_paginaactual1ActionPerformed(evt);
            }
        });

        jbtn_siguiente1.setIcon(resourceMap.getIcon("jbtn_siguiente1.icon")); // NOI18N
        jbtn_siguiente1.setText(resourceMap.getString("jbtn_siguiente1.text")); // NOI18N
        jbtn_siguiente1.setName("jbtn_siguiente1"); // NOI18N
        jbtn_siguiente1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_siguiente1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(190, 190, 190)
                .addComponent(jtf_fotosartxpag1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(50, 50, 50)
                .addComponent(jlbl_paginas2)
                .addGap(27, 27, 27)
                .addComponent(jbtn_anterior1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jtf_paginaactual1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_siguiente1)
                .addContainerGap(229, Short.MAX_VALUE))
            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 836, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(349, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlbl_paginas2)
                    .addComponent(jbtn_anterior1)
                    .addComponent(jbtn_siguiente1)
                    .addComponent(jtf_paginaactual1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_fotosartxpag1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup()
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 341, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(44, Short.MAX_VALUE)))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel6.TabConstraints.tabTitle"), jPanel6); // NOI18N

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
        jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
        jmni_salir.setName("jmni_salir"); // NOI18N
        jmni_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_salirActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_salir);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jmni_escapar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        jmni_escapar.setText(resourceMap.getString("jmni_escapar.text")); // NOI18N
        jmni_escapar.setName("jmni_escapar"); // NOI18N
        jmni_escapar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_escaparActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_escapar);

        jMenuBar1.add(jMenu2);

        jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
        jMenu3.setName("jMenu3"); // NOI18N
        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
      if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0) {
             this.dispose();
        }
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jmni_escaparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escaparActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escaparActionPerformed

    private void jbtn_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_salirActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
}//GEN-LAST:event_jbtn_salirActionPerformed

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        // TODO add your handling code here:
         indexactual=this.jTabbedPane1.getSelectedIndex();
          if((indexactual==1)&&(yacarguecancel==0))
                {
                   yacarguecancel=1;
                   String a_tiendas[]=this.jtf_tienda.getText().toString().split(":");
                   this.carga_datos_cobros_cancelacion(1,a_tiendas[0],this.jtf_folio.getText(), "");
                   this.carga_datos_fotospaginacion(0);
                }
         if(indexactual==2)
                {
                   this.carga_datos_fotospaginacion(0);
                }
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void jtbn_clietestadisticaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtbn_clietestadisticaActionPerformed
        // TODO add your handling code here:
        String idcliente[]=this.jtf_cliente.getText().split(":") ;
        //JFrame mainFrame = Sie_invdisApp.getApplication().getMainFrame();
        if(Integer.valueOf(idcliente[0])>0)
            {
                monedero_sie_catalogo_detalle fmscd=new monedero_sie_catalogo_detalle("",idcliente[0]);
                fmscd.pack();
                fmscd.setVisible(true);
            }
}//GEN-LAST:event_jtbn_clietestadisticaActionPerformed

    private void jtf_fotosartxpag1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_fotosartxpag1ActionPerformed
        // TODO add your handling code here:
        this.carga_datos_fotospaginacion(Integer.valueOf(this.jtf_paginaactual1.getText().toString()));
}//GEN-LAST:event_jtf_fotosartxpag1ActionPerformed

    private void jbtn_anterior1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_anterior1ActionPerformed
        // TODO add your handling code here:
        this.jtf_paginaactual1.setText(String.valueOf(Integer.valueOf(this.jtf_paginaactual1.getText().toString())-1));
        System.out.println("Esta es la pagina que mando"+this.jtf_paginaactual1.getText());
        this.carga_datos_fotospaginacion(Integer.valueOf(this.jtf_paginaactual1.getText().toString()));
}//GEN-LAST:event_jbtn_anterior1ActionPerformed

    private void jtf_paginaactual1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_paginaactual1ActionPerformed
        // TODO add your handling code here:
        this.carga_datos_fotospaginacion(Integer.valueOf(this.jtf_paginaactual1.getText().toString()));
}//GEN-LAST:event_jtf_paginaactual1ActionPerformed

    private void jbtn_siguiente1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_siguiente1ActionPerformed
        // TODO add your handling code here:
        this.jtf_paginaactual1.setText(String.valueOf(Integer.valueOf(this.jtf_paginaactual1.getText().toString())+1));
        System.out.println("Esta es la pagina que mando"+this.jtf_paginaactual1.getText());
        this.carga_datos_fotospaginacion(Integer.valueOf(this.jtf_paginaactual1.getText().toString()));
}//GEN-LAST:event_jbtn_siguiente1ActionPerformed

   

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //ventas_sie_apartados_detalle dialog = new ventas_sie_apartados_detalle(new javax.swing.JFrame(), true);
                 new ventas_sie_apartados_detalle().setVisible(true);
                //dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtn_anterior1;
    private javax.swing.JButton jbtn_salir;
    private javax.swing.JButton jbtn_siguiente1;
    private javax.swing.JEditorPane jepn_fotos;
    private javax.swing.JLabel jlbl_paginas2;
    private javax.swing.JMenuItem jmni_escapar;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JTable jtbl_detalleapartado;
    private javax.swing.JTable jtbl_movimiento;
    private javax.swing.JButton jtbn_clietestadistica;
    private javax.swing.JTextField jtf_abonos;
    private javax.swing.JTextField jtf_cliente;
    private javax.swing.JTextField jtf_direccion;
    private javax.swing.JTextField jtf_fechaapartado;
    private javax.swing.JTextField jtf_folio;
    private javax.swing.JTextField jtf_fotosartxpag1;
    private javax.swing.JTextField jtf_importe;
    private javax.swing.JTextField jtf_paginaactual1;
    private javax.swing.JTextField jtf_saldo;
    private javax.swing.JTextField jtf_status;
    private javax.swing.JTextField jtf_telefono;
    private javax.swing.JTextField jtf_tienda;
    private javax.swing.JTextField jtf_vencimiento;
    private javax.swing.JEditorPane jtp_razoncancela;
    // End of variables declaration//GEN-END:variables

}
